home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 4.0 KB | 146 lines | [TEXT/ToyS] |
- property kasWinDims : {320, 240}
- property kasHtHead : {"<HTML>", "<HEAD>", "<TITLE>", "Akua's Icon Table", "</TITLE>", "</HEAD>", "<BODY>"}
- property kasHtTail : {"</BODY>", "</HTML>"}
- property kasTblHead : {"<TABLE BORDER=4 CELLPADDING=4 CELLSPACING=2>"}
- property kasRowHead : {"<TR>", "<TD VALIGN=top>"} -- Name goes after this
- property kasRowDiv1 : {"</TD>", "<TD VALIGN=top>"} -- Number goes after this
- property kasRowDiv2 : {"</TD>", "<TD>"} -- Img tag goes after this
- property kasRowTail : {"</TD>", "</TR>"}
- property kasTblTail : {"</TABLE>"}
-
- property kasImgTag : "<IMG"
- property kasImgH : "HEIGHT"
- property kasImgW : "WIDTH"
- property kasImgSrc : "SRC"
-
- property kasExportFormat : "JPEG" -- QT Supports JPEG, BMP or QTIF but not GIF
- property kasExtension : ".jpg"
-
- global gasDrawWin
-
-
- on open fsObjs
- repeat with fsObj in fsObjs
- set gasDrawWin to ¬
- display drawing titled ¬
- "Color Icons to HTML" with dimensions kasWinDims
-
- -- Create output folder
- set fsInf to extended info for fsObj
- set fsDad to (parent spec of fsInf) as string
- set outFold to («event ÅkuFƒNew» fsDad given «class NAME»:"icons") as string
-
- -- Start stuff
- set winBox to {0, 0} & kasWinDims
- set icnBox to {0, 16} & kasWinDims
- set txtBox to {0, 0, item 1 of kasWinDims, 16}
- set html to kasHtHead & kasTblHead
-
- -- Black background
- draw a box into gasDrawWin ¬
- inside of winBox ¬
- filling it with the pen
-
- -- Get icons
- set idx to 1
- repeat while true
- try
- set ciRsc to the resource in fsObj ¬
- of type ¬
- "cicn" with index idx ¬
- with its info
- on error
- exit repeat
- end try
-
- -- Break it down
- set ciName to item 1 of ciRsc
- set ciNum to item 2 of ciRsc
- set ciData to item 3 of ciRsc
-
- -- Convert to picture, get bounds
- set ciPic to ciData as picture
- set ciInf to the picture info for ciPic
- set ciBox to picture bounds of ciInf
- set ciDrawBox to CenterBox(ciBox, icnBox)
-
- -- Add row to table
- set ciW to compile tag val {kasImgW, (item 3 of ciBox) - (item 1 of ciBox)}
- set ciH to compile tag val {kasImgH, (item 4 of ciBox) - (item 1 of ciBox)}
- set ciS to compile tag val {kasImgSrc, "icons/" & ciNum & kasExtension}
- set imgTag to compile tag {kasImgTag, ciW, ciH, ciS}
- set html to html & kasRowHead & ciName & kasRowDiv1 & ("#" & ciNum) & kasRowDiv2 & imgTag & kasRowTail
-
- -- Erase background
- draw a box into gasDrawWin ¬
- inside of winBox ¬
- filling it with the pen ¬
- without recording
-
- -- Show name
- draw a text box into gasDrawWin ¬
- inside of txtBox ¬
- using data ciName ¬
- using state {text mode:2} ¬
- justified flush left ¬
- without recording
-
- -- Show number
- draw a text box into gasDrawWin ¬
- inside of txtBox ¬
- using data ("Idx:" & idx & " #" & ciNum) ¬
- using state {text mode:2} ¬
- justified flush right ¬
- without recording
-
- -- Draw Icon
- draw a picture into gasDrawWin ¬
- inside of ciDrawBox ¬
- using data ciPic ¬
- without recording
-
- -- Save file
- store image ciPic ¬
- in (outFold & ciNum & kasExtension) ¬
- given «class îKnd»:kasExportFormat
-
- -- Advance to next 'cicn'
- set idx to idx + 1
- -- if (idx > 100) then exit repeat -- Just testing
- end repeat
-
- set html to html & kasTblTail & kasHtTail
- set htTxt to compile ML html
-
- -- Write html to file
- set fRef to ¬
- open fork from fsDad ¬
- named "icon_index.html" of type "TEXT" of creator "R*ch" with write access
- write data to fRef from buffer htTxt
- close fork fRef
- end repeat
- end open
-
-
- on quit
- display drawing gasDrawWin with disposal
- return (continue quit)
- end quit
-
-
- on CenterBox(src, dst)
- -- Place src in dst w/o scaling
- set dX to (item 1 of dst)
- set dY to (item 2 of dst)
- set sW to (item 3 of src) - (item 1 of src)
- set sH to (item 4 of src) - (item 2 of src)
- set dW to (item 3 of dst) - dX
- set dH to (item 4 of dst) - dY
-
- set bW to dX + (dW - sW) / 2
- set bH to dY + (dH - sH) / 2
-
- -- Center it
- return {bW, bH, bW + sW, bH + sH}
- end CenterBox
-